<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>添加用户名</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__PUBLIC__/css/font.css">
    <link rel="stylesheet" href="__PUBLIC__/css/xadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
      .displaynone{
        display: none;
      }
    </style>
  </head>
  <body>
    <div class="x-nav">
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
  <div class="x-body">
    <form class="layui-form">
     
          <input type="hidden" name="id" value="{$id}">
      <div class="layui-form-item" style="text-align: center;margin-top:20px;">
        <label for="L_email" class="layui-form-label">
            <span class="x-red">*</span>标题名称：
        </label>
        <div class="layui-input-inline">
            <input type="text" id="title" name="title" class="layui-input" value="{$know['title']}">
        </div>
      </div>
      <div class="layui-form-item" style="text-align: center;margin-top:20px;">
        <label for="L_email" class="layui-form-label">
            <span class="x-red">*</span>内容：
        </label>
        <div class="layui-input-inline">
            <textarea name="content" id="content">{$know['content']}</textarea>
        </div>
      </div>
      <div class="layui-form-item">
            <label class="layui-form-label">
                  苗木类别：
            </label>
            <div class="layui-input-inline">
              <select name="parentid" lay-verify="" lay-filter="a" id="parentid">
                <option value="0">请选择苗木类别</option>
                <foreach name="s" item="y">
                  <option value="{$y['id']}">{$y['sort']}</option>
                </foreach>
              </select>
            </div>
          </div>
      <div class="layui-form-item" style="text-align: center;margin-top:20px;">
        <button  class="layui-btn" lay-filter="add" lay-submit="">
            开始上传
        </button>
      </div>
    </form>
  </div>
  </body>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="__PUBLIC__/js/xadmin.js"></script>
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript">
        UE.getEditor('content',{
          initialFrameWidth:800,
          initialFrameHeight:200
        })
      </script>
<script type="text/javascript">
   layui.use(['form','layer'], function(){
          $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          form.on('submit(add)',function(){
            if($('#title').val() == ''){
              layer.msg('请输入标题!!');
              return false;
            }
            if($('#parentid').val()==0){
              layer.msg('请选择类别!!');
                return false;
            }
              $.ajax({
                  url:"{:U('save_know')}",
                  type:"post",
                  // Form数据
                  data:$("form").serialize(),
                  success:function(data){
                      if(data==1){
                        layer.alert("增加成功", {icon: 6},function(){
                          parent.location.reload();
                        });
                      }else{
                        layer.msg('数据未添加成功');
                      }
                  }
              });
              return false;
          }) 
  })
</script>
</html>